<?php
class Menu
{
    var $secciones = array();
    var $url = array();

    var $Items = '';

    var $Template;
    var $Cuerpo;

    var $Debug;
    var $id_usuario = -1;

    function Menu($tpl_cuerpo, $debug = 0)
    {
        if ($debug)
        {
            $this->Debug = new Debug();
            $this->Debug->Activo = 1;
        }
        $this->Template = $tpl_cuerpo;
        if (is_readable($this->Template))
        {
            $this->Cuerpo = @file_get_contents($this->Template);
        } elseif ($this->Debug->Activo){
            $this->Debug->Mostrar(2, $this->Template);
        }
    }
    function Agregar_Seccion($titulo = '', $url = '', $default = false)
    {
        $this->secciones[] = $titulo;
        $this->url[] = $url;
        if ($default)
        {
            $this->default = $url;
        }
    }
    function Mostrar()
    {
        $keys = (TIPOS_ADMIN) ? array_keys($_SESSION['TIPOS_ADMIN'][$this->id_usuario]) : array();
        foreach ($this->secciones as $id => $seccion)
        {
            parse_str(str_replace('?', '', $this->url[$id]));
            if (empty($keys) || in_array('*', $keys) || in_array($page, $keys))
            {
                $this->Items .= str_replace('<!--URL-->', $this->url[$id], str_replace('<!--SECCION-->', $seccion, $this->Cuerpo));
            }
        }
        return $this->Items;
    }
}


?>